package org.openlab.service.impl;

import java.io.Serializable;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.openlab.dao.BaseDao;
import org.openlab.service.BaseService;
import org.springframework.transaction.annotation.Transactional;

@Transactional
public abstract class BaseServiceImpl<T, PK extends Serializable> implements BaseService<T, PK> {

	protected final Log log = LogFactory.getLog(getClass());
	
	protected BaseDao<T, PK> dao;
	
	public BaseServiceImpl(BaseDao<T, PK> dao) {
		this.dao = dao;
	}
	
	@Override
	public List<T> getAll() {
		return dao.getAll();
	}

	@Override
	public List<T> getAllDistinct() {
		return dao.getAllDistinct();
	}

	@Override
	public T get(PK id) {
		return dao.get(id);
	}

	@Override
	public boolean exists(PK id) {
		return dao.exists(id);
	}

	@Override
	public T save(T entity) {
		return dao.save(entity);
	}

	@Override
	public void remove(PK id) {
		dao.remove(id);		
	}
	
}
